
local BagCtrl={}

function BagCtrl:init()
    NetEngine:registerCallback(ProtoCmd.ResAddItemMessage,function(msg)
        if msg.param.bType == 2 then
            if msg.param.maxcount then
                DyTransportPack:setPacks(msg.param.maxcount)
            end
            for k,v in pairs(msg.param) do
                if type(v) == "table" then
                    DyTransportPack:setItem({id=v[1],count=v[2],idx=tonumber(k)},true)
                elseif tonumber(k) and type(v)=="number" then
                    DyTransportPack:clearItem(tonumber(k))
                elseif k=="maxcount" then
                    DyTransportPack:setPacks(v)
                end
            end
            if DyTransportPack:getDragState() then
                FzEventCenter:DispichEvent(FzEvent.UpdateTradeingInfo)
                DyTransportPack:getDragState(false)
            end
        end
    end)
    NetEngine:registerCallback(ProtoCmd.ResHorseUpMessage,function(msg)
        print("ResHorseUpMessage")
        Alert:show("",Language.pack.pack2upgradesuccess,Alert.TYPE_OK,function()
            
        end)
    end)
end

function BagCtrl:clean()
    NetEngine:unregisterCallback(ProtoCmd.ResAddItemMessage)
    NetEngine:unregisterCallback(ProtoCmd.ResHorseUpMessage)
end

return BagCtrl
